home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Interfaces / PInterfaces / UBusyCursor.p < prev    next >
Encoding:
Text File  |  1990-10-25  |  3.6 KB  |  98 lines  |  [TEXT/MPS ]

  1. {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
  2. { UBusyCursor.p }
  3. { Copyright © 1985-1990 Apple Computer, Inc.    All rights reserved. }
  4. {[f-]}
  5. {
  6.             T H E O R Y   O F     O P E R A T I O N
  7.  
  8. The UBusyCursor unit implements a mechanism for automatically setting
  9. the cursor to the watch when the application is "busy."
  10.  
  11. An application is considered "busy" if it hasn't called GetNextEvent
  12. or EventAvail for a given number of ticks, where 60 ticks equals one
  13. second.  The default time is defined by kWatchDelay, which is 120 ticks
  14. or 2 seconds--it can be changed by calling BusyDelay.    After this period
  15. of time has elapsed with no call to GetNextEvent or EventAvail, the
  16. cursor is changed to the watch.  On the next call to GetNextEvent or
  17. EventAvail, the cursor is restored to its state before it was changed to
  18. the watch.
  19.  
  20. Changing the cursor to the watch is done by the VBL task AWatchTask.
  21. AWatchTask's execution frequency is set to kWatchDelay, or by calling
  22. BusyDelay.    When AWatchTask is executed it sets the cursor to the
  23. watch and resets AWatchTask's vblCount.
  24.  
  25. The traps InitCursor, SetCursor and SetCCursor are patched so that
  26. they "remember" the cursor being set before executing the trap.  This
  27. will allow us to restore the cursor after it has been changed to the
  28. busy watch.
  29.  
  30. The EventAvail and GetNextEvent traps are patched such that, before
  31. executing the trap, AWatchTask's vblCount is reset, and if the busy
  32. cursor is displayed, then the cursor is restored to the last cursor
  33. set by SetCursor or SetCCursor.
  34. }
  35. {[f+]}
  36. {$IFC UNDEFINED UsingIncludes}
  37. {$SETC UsingIncludes := FALSE}
  38. {$ENDC}
  39.  
  40. {$IFC NOT UsingIncludes}
  41. UNIT UBusyCursor;
  42.  
  43.     INTERFACE
  44.         {$ENDC}
  45.  
  46.         {$IFC UNDEFINED __UBusyCursor__}
  47.         {$SETC __UBusyCursor__ := FALSE}
  48.         {$ENDC}
  49.  
  50.         {$IFC NOT __UBusyCursor__}
  51.         {$SETC __UBusyCursor__ := TRUE}
  52.  
  53.         { • Auto-Include the requirements for this unit's interface. }
  54.         {$SETC UBusyCursorIncludes := UsingIncludes}
  55.         {$SETC UsingIncludes := TRUE}
  56.         {$I+}
  57.         {$IFC UNDEFINED UsingTypes} {$I Types.p} {$ENDC}
  58.         {$SETC UsingIncludes := UBusyCursorIncludes}
  59.  
  60.         CONST
  61.             kWatchDelay         = 2 * 60;                {default # of 1/60 sec. ticks before cursor
  62.                                                          changes to a watch}
  63.  
  64.         PROCEDURE InitUBusyCursor;
  65.         { Initialize the unit. }
  66.  
  67.         PROCEDURE BusyActivate(entering: BOOLEAN);
  68.         { Call BusyActivate if you want to activate or deactivate the busy cursor mechanism. This is
  69.         call by MacApp when losing/gaining control to a desk accessory or switcher partition. }
  70.  
  71.         PROCEDURE BusyDelay(newDelay: INTEGER);
  72.         { Call BusyDelay if you want to change the busy cursor delay. newDelay should be in 1/60
  73.         seconds; a value <= 0 means don't change the cursor. (BusyDelay respects the state flags
  74.         in the cursor info record (ie., changeToWatch and inControl.) }
  75.  
  76.         PROCEDURE ForceBusy;
  77.         { Puts up the watch immediately }
  78.  
  79.         PROCEDURE ResetBusyCursor;
  80.         { Call ResetBusyCursor if you want to change the cursor back to an arrow and reset the time
  81.         before changing back to a watch. This is not usually called directly by the application.
  82.         Instead, it is called each time GetNextEvent and EventAvail is called, by patches installed
  83.         by BusyInstall. }
  84.  
  85.         PROCEDURE BusyInstall;
  86.         { BusyInstall installs the busy cursor mechanism. Typically this is called once during
  87.         program initialization. It installs the VBL task and patches the traps GetNextEvent,
  88.         EventAvail, InitCursor, SetCursor and SetCCursor. }
  89.  
  90.         PROCEDURE BusyRemove;
  91.         { BusyRemove uninstalls the busy cursor mechanism. Typically this is called once during
  92.         program termination. It removes the VBL task and unpatches the patched traps. }
  93.         {$ENDC}
  94.  
  95.         {$IFC NOT UsingIncludes}
  96. END.
  97. {$ENDC}
  98.